home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / gfx / 3d / irit50src.lha / irit5 / grapdrvs / draw_crv.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-04  |  3.3 KB  |  91 lines

  1. /*****************************************************************************
  2. *   Default curve drawing routine common to graphics drivers.             *
  3. *                                         *
  4. * Written by:  Gershon Elber                Ver 0.1, June 1993.  *
  5. *****************************************************************************/
  6.  
  7. #include "irit_sm.h"
  8. #include "iritprsr.h"
  9. #include "allocate.h"
  10. #include "ip_cnvrt.h"
  11. #include "cagd_lib.h"
  12. #include "symb_lib.h"
  13. #include "iritgrap.h"
  14.  
  15. /*****************************************************************************
  16. * DESCRIPTION:                                                               M
  17. * Draw a single Curve object using current modes and transformations.         M
  18. *   Curve must be with either E3 or P3 point type and must be a NURB curve.  M
  19. *   Piecewise linear approximation is cashed under "_isoline" and "_ctlpoly" M
  20. * attributes of PObj.                                 M
  21. *                                                                            *
  22. * PARAMETERS:                                                                M
  23. *   PObj:     A curve object to draw.                                        M
  24. *                                                                            *
  25. * RETURN VALUE:                                                              M
  26. *   void                                                                     M
  27. *                                                                            *
  28. * KEYWORDS:                                                                  M
  29. *   IGDrawCurve                                                              M
  30. *****************************************************************************/
  31. void IGDrawCurve(IPObjectStruct *PObj)
  32. {
  33.     IPObjectStruct *PObjPolylines, *PObjCtlPolys;
  34.  
  35.     if ((PObjPolylines = AttrGetObjectObjAttrib(PObj, "_isoline")) == NULL) {
  36.     CagdCrvStruct *Crv,
  37.         *Crvs = PObj -> U.Crvs;
  38.     IPPolygonStruct *PPolyline;
  39.  
  40.     PObjPolylines = IPAllocObject("", IP_OBJ_POLY, NULL);
  41.     PObjPolylines -> Attrs = AttrCopyAttributes(PObj -> Attrs);
  42.     IP_SET_POLYLINE_OBJ(PObjPolylines);
  43.     for (Crv = Crvs; Crv != NULL; Crv = Crv -> Pnext) {
  44.         PPolyline = IritCurve2Polylines(Crv, IGGlblSamplesPerCurve,
  45.                         IGGlblPolylineOptiApprox);
  46.  
  47.         if (PPolyline != NULL) { 
  48.         PPolyline -> Pnext = PObjPolylines -> U.Pl;
  49.         PObjPolylines -> U.Pl = PPolyline;
  50.         }
  51.     }
  52.     if (IGGlblCacheGeom)
  53.         AttrSetObjectObjAttrib(PObj, "_isoline", PObjPolylines, FALSE);
  54.     }
  55.  
  56.     if (PObjPolylines != NULL) {
  57.     IGDrawPoly(PObjPolylines);
  58.  
  59.     if (!IGGlblCacheGeom)
  60.         IPFreeObject(PObjPolylines);
  61.     }
  62.  
  63.     if (IGGlblDrawSurfaceMesh) {
  64.     if ((PObjCtlPolys = AttrGetObjectObjAttrib(PObj, "_ctlpoly"))
  65.                                 == NULL) {
  66.         CagdCrvStruct *Crv,
  67.         *Crvs = PObj -> U.Crvs;
  68.         IPPolygonStruct *PCtlPoly;
  69.  
  70.         PObjCtlPolys = IPAllocObject("", IP_OBJ_POLY, NULL);
  71.         PObjCtlPolys -> Attrs = AttrCopyAttributes(PObj -> Attrs);
  72.         IP_SET_POLYLINE_OBJ(PObjCtlPolys);
  73.         for (Crv = Crvs; Crv != NULL; Crv = Crv -> Pnext) {
  74.         PCtlPoly = IritCurve2CtlPoly(Crv);
  75.  
  76.         PCtlPoly -> Pnext = PObjCtlPolys -> U.Pl;
  77.         PObjCtlPolys -> U.Pl = PCtlPoly;
  78.         }
  79.         if (IGGlblCacheGeom)
  80.         AttrSetObjectObjAttrib(PObj, "_ctlpoly", PObjCtlPolys, FALSE);
  81.     }
  82.  
  83.     if (PObjCtlPolys != NULL) {
  84.         IGDrawPoly(PObjCtlPolys);
  85.  
  86.         if (!IGGlblCacheGeom)
  87.         IPFreeObject(PObjCtlPolys);
  88.     }
  89.     }
  90. }
  91.